/*  
 * Actipro Software's WPF DataGrid / Editors Integration Add-on
 * http://actipro.codeplex.com/
 * 
 * Copyright (c) 2009-2015 Actipro Software LLC. 
 *  
 * This source code is subject to the terms of the Microsoft Public License (Ms-PL). 
 *  
 * Redistribution and use in source and binary forms, with or without modification, 
 * is permitted provided that redistributions of the source code retain the above 
 * copyright notices and this file header. 
 *  
 * Additional copyright notices should be appended to the list above. 
 * 
 * For details, see <http://www.opensource.org/licenses/ms-pl.html>. 
 *  
 * All other rights reserved. 
 *
 */  


using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using ActiproSoftware.Windows.Controls.Editors.Interop.DataGrid.Primitives;

namespace ActiproSoftware.Windows.Controls.Editors.Interop.DataGrid {

	/// <summary>
	/// Represents a data-bound column for use in a <c>DataGrid</c> that utilizes the <see cref="SizeEditBox"/>.
	/// </summary>
	[SuppressMessage("Microsoft.Maintainability", "CA1501:AvoidExcessiveInheritance")]
	public class DataGridSizeColumn : DataGridDoubleEditBoxColumnBase<Size?> {

		#region Dependency Properties

		/// <summary>
		/// Identifies the <see cref="EditableParts"/> dependency property.  This field is read-only.
		/// </summary>
		/// <value>The identifier for the <see cref="EditableParts"/> dependency property.</value>
		public static readonly DependencyProperty EditablePartsProperty = SizeEditBox.EditablePartsProperty.AddOwner(typeof(DataGridSizeColumn),
			new FrameworkPropertyMetadata(SizeEditableParts.All, OnNotifyablePropertyValueChanged));

		#endregion // Dependency Properties

		/////////////////////////////////////////////////////////////////////////////////////////////////////
		#region PUBLIC PROCEDURES
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Applies standard values to the specified target element.
		/// </summary>
		/// <param name="targetElement">The target element.</param>
		protected override void ApplyStandardValues(FrameworkElement targetElement) {
			if (targetElement is SizeEditBox) {
				this.ApplyValue(EditablePartsProperty, targetElement, SizeEditBox.EditablePartsProperty);
			}
			base.ApplyStandardValues(targetElement);
		}

		/// <summary>
		/// Gets or sets the parts that are editable.
		/// This is a dependency property.
		/// </summary>
		/// <value>
		/// The parts that are editable.
		/// The default value is <c>SizeEditableParts.All</c>.
		/// </value>
		public SizeEditableParts EditableParts {
			get { return (SizeEditableParts)this.GetValue(DataGridSizeColumn.EditablePartsProperty); }
			set { this.SetValue(DataGridSizeColumn.EditablePartsProperty, value); }
		}

		/// <summary>
		/// Gets the type of the edit box.
		/// </summary>
		/// <returns>The <see cref="SizeEditBox"/> type.</returns>
		protected override Type GetEditBoxType() {
			return typeof(SizeEditBox);
		}

		#endregion // PUBLIC PROCEDURES
	}
}
